<?php
//phpinfo();
// Define /main directory for code file
ini_set('upload_tmp_dir','/home/hoangvv/tmp');
ini_set('display_errors', 1);
error_reporting(E_ALL);
session_start(); 

define('ROOT', dirname(__FILE__));
define('APPLICATION', realpath(dirname(__FILE__).'/Application'));
define('SYSTEM', realpath(dirname(__FILE__).'/System'));
define('CONTROLLER', realpath(dirname(__FILE__).'/Application/Controllers'));
define('MODEL', realpath(dirname(__FILE__).'/Application/Models'));
define('VIEW', realpath(dirname(__FILE__).'/Application/Views'));
define('SCRIPT', realpath(dirname(__FILE__).'/Script'));
define('UPLOAD', realpath(dirname(__FILE__).'/Upload'));

require_once (ROOT.'/Config.php');
require_once (SYSTEM.'/Boostrap.php');
require_once (SYSTEM.'/Routes.php');
include_once (SYSTEM.'/Pattern.php');
include_once (SYSTEM.'/Route.php');
include_once (SYSTEM.'/Authencate.php');

$RoutesCollection = new Routes();
RegisterRoutes($RoutesCollection);

$boostrapObject = new Boostrap($RoutesCollection);
$boostrapObject->Start();

function RegisterRoutes($routes)
{    
	$pattern = new URLPattern('{Controller}', 'Home', 'Index');
	$routes->AddRoutes($pattern);
	
	$pattern = new URLPattern('{Controller}/{Action}/{ID}/{Title}', 'Home', 'Index', array('ID' => '20'));
	$routes->AddRoutes($pattern);
	
	$pattern = new URLPattern('{Controller}/{Action}', 'Home', 'Index');
	$routes->AddRoutes($pattern);	
}
